<script setup lang="ts">
import { provide, ref } from 'vue'
import ParentComp from './components/03.后代数据传递/ParentComp.vue'

// 1. app组件数据传递给child
const count = ref(998)

// 2. app组件函数传递给child，调用的时候可以回传数据
const updateCount = (num: number) => {
  count.value += num
}

// count 传递给后代
provide('count', count)
// updateCount 回调函数传递给后代
provide('updateCount', updateCount)
</script>

<template>
  <div class="app-page" style="border: 10px solid #ccc; padding: 50px; width: 600px">
    app 组件 {{ count }} updateCount
    <ParentComp />
  </div>
</template>
